<?php

namespace app\index\controller;

use app\index\controller\Base;
use think\Request;
use think\Db;



class Post extends Base
{


    //  显示发表帖子页面 
     public function dzhpost()
    {
        $M = model('Post');
        $this->assign('title','发表帖子');
        $this->assign('channel',$M->getchannels());
        return $this->fetch();
    }

    // 执行发帖
     public function tjpost()
    {
        $M = model('Post');
        $data = $M->doadd();
        // 判断结果
        if($data){
            $this->success('发表成功', '/index');
        } else {
            $this->error('发表失败');
        }
    }

    // 获取标签信息
     public function getlabel($id)
    {
        $label = db('label')->where('pid',$id)->select();
        return json_encode($label);
    }
}
